<template>
    <div>
        <el-upload
            :limit="1"
            :file-list="fileList"
            :beforeUpload="beforeUpload"
            action=""
        >
            <el-button size="small" type="warning">点击上传</el-button>
        </el-upload>
        <vue-office-docx :src="src"/>
        <!-- <vue-office-excel :src="src"/> -->
        <vue-office-pdf :src="src"/>
    </div>
</template>

<script setup>
import { ref } from 'vue';
import VueOfficeDocx from '@vue-office/docx'
import VueOfficePdf from '@vue-office/pdf'
// import VueOfficeExcel from '@vue-office/excel'
import '@vue-office/docx/lib/index.css' 
// import '@vue-office/excel/lib/index.css'

const src = ref('');
const fileList = ref([]);

const beforeUpload = (file) => {
    console.log('file',file);
    let reader = new FileReader();
    console.log('reader',reader);
    reader.readAsArrayBuffer(file);
    console.log(reader);
    console.log('file',file);
    reader.onload = (loadEvent) => {
        console.log('loadEvent',loadEvent);
        let arrayBuffer = loadEvent.target.result;
        src.value = arrayBuffer;
    };
    return false;
};
</script>
